import 'package:erp_widget/erp_widget.dart';
import 'package:flutter/material.dart';

class DxTools {
  const DxTools._();

  /// 判空
  static bool isEmpty(Object? obj) {
    if (obj is String) {
      return obj.isEmpty;
    }
    if (obj is Iterable) {
      return obj.isEmpty;
    }
    if (obj is Map) {
      return obj.isEmpty;
    }
    return obj == null;
  }

  static bool isBoss = false;

  /// 没有权限或者VIP弹窗
  static void noVip(BuildContext context) {
    if(isBoss) {
      DxDialog.confirm(
        context,
        builder: (_) => Padding(
          padding: const EdgeInsets.symmetric(vertical: 30).h,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(DxAsset.vip, width: 112, height: 96, fit: BoxFit.cover, package: 'erp_widget'),
              const SizedBox(height: 15),
              const Text('此功能需要升级VIP'),
            ],
          ),
        ),
        cancelButtonText: '残忍拒绝',
        confirmButtonText: '立即升级',
        onConfirm: () {
          Future.delayed(const Duration(milliseconds: 300), () {
            Navigator.pushNamed(context, '/membership_purchase');
          });
        },
      );
    } else {
      DxDialog.alert(
        context,
        title: '提示',
        content: '您没有权限, 请联系超级管理员开通',
      );
    }
  }
}
